#include <benchmark/benchmark.h>
#include <queue>
#include <string>

struct Node {
    int key;
    std::string payload;
    Node(int k, std::string p) : key(k), payload(std::move(p)) {}
    bool operator<(const Node& other) const { return key < other.key; }
};

static void PriorityPush(benchmark::State& state) {
    for (auto _ : state) {
        std::priority_queue<Node> pq;
        for (int i = 0; i < state.range(0); ++i) {
            Node node(i, "payload");
            pq.push(node); // 拷贝
        }
        benchmark::ClobberMemory();
    }
}
BENCHMARK(PriorityPush)->RangeMultiplier(2)->Range(64, 1 << 15);

static void PriorityEmplace(benchmark::State& state) {
    for (auto _ : state) {
        std::priority_queue<Node> pq;
        for (int i = 0; i < state.range(0); ++i) {
            pq.emplace(i, "payload"); // 原位构造
        }
        benchmark::ClobberMemory();
    }
}
BENCHMARK(PriorityEmplace)->RangeMultiplier(2)->Range(64, 1 << 15);

BENCHMARK_MAIN();